import 'package:flutter/material.dart';
import 'package:flutterapp/src/getX/shop/show_item_widget.dart';
import 'package:get/get.dart';

import 'shop_controller.dart';
import 'shop_model.dart';

class ListItemWiget extends StatefulWidget {
  final ShopModel element;
  ListItemWiget(this.element);

  @override
  _ListItemWigetState createState() => _ListItemWigetState();
}

class _ListItemWigetState extends State<ListItemWiget> {
  // 注入
  ShopController _shopController = Get.put(ShopController());

  @override
  void initState() {
    super.initState();
    _shopController.requstShopGoodsList(widget.element);
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder(
        id: "${widget.element.id}",
        builder: (ShopController controller) {
          List<GoodsModel> list = controller.currentList;
          return ListView.builder(
            itemCount: 100,
            itemBuilder: (BuildContext context, int index) {
              return ShopItemWidget(list[index]);
            },
          );
        });
  }
}
